package cn.bandeqing.frame.controller;

import cn.bandeqing.attachment.req.AttachmentListReq;
import cn.bandeqing.attachment.req.AttachmentUploadReq;
import cn.bandeqing.attachment.req.RemoveReq;
import cn.bandeqing.attachment.resp.AttachmentDetail;
import cn.bandeqing.attachment.rpc.IAttachmentRpc;
import cn.bandeqing.base.resp.Resp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "附件")
@RequestMapping("/attachment")
@RestController
public class AttachmentController {

    @DubboReference
    private IAttachmentRpc attachmentRpc;

    @Operation(summary = "附件列表")
    @PostMapping("/list")
    public Resp<List<AttachmentDetail>> list(@RequestBody @Valid AttachmentListReq req) {
        return attachmentRpc.list(req);
    }

    @Operation(summary = "上传")
    @PostMapping("/upload")
    public Resp<Void> upload(@RequestBody @Valid AttachmentUploadReq req) {
        return attachmentRpc.upload(req);
    }

    @Operation(summary = "删除")
    @PostMapping("/remove")
    public Resp<Void> remove(@RequestBody @Valid RemoveReq req) {
        return attachmentRpc.remove(req);
    }

}
